#ifndef SERIAL_H
#define SERIAL_H
#include <sys/types.h>
#include <stdint.h>

#include <termios.h>
#include <stddef.h>

int serial_fd;

typedef struct {
    int baud_rate;
    char parity;
    int data_bits;
    int stop_bits;
} SerialConfig;

int serial_open(const char *port, const SerialConfig *config);
void serial_close(int fd);
int serial_read(int fd, uint8_t *buffer, size_t length);
int serial_write(int fd, const uint8_t *data, size_t length);

#endif // SERIAL_H